using S.O.Domain;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace S.O.Domain.Medical
{
    /// <summary>
    /// 病历记录实体类
    /// 存储患者的完整病历信息，包括主诉、病史、检查结果和治疗建议等
    /// </summary>
    [Table("MedicalRecords")]
    public class MedicalRecordModel : BaseEntity
    {
        /// <summary>
        /// 病历记录ID（主键）
        /// 格式：MR + 年月日 + 6位序号，如：MR20241201000001
        /// </summary>
        [Key]
        [StringLength(20)]
        [Column("Id")]
        public string Id { get; set; } = string.Empty;

        /// <summary>
        /// 患者ID（外键）
        /// 关联到Patient表
        /// </summary>
        [Required]
        [Column("PatientId")]
        public long PatientId { get; set; }

        /// <summary>
        /// 患者姓名
        /// 冗余字段，便于查询和显示
        /// </summary>
        [Required]
        [StringLength(50)]
        [Column("PatientName")]
        public string PatientName { get; set; } = string.Empty;

        /// <summary>
        /// 主诉
        /// 患者的主要症状和就诊原因
        /// </summary>
        [Required]
        [StringLength(500)]
        [Column("ChiefComplaint")]
        public string ChiefComplaint { get; set; } = string.Empty;

        /// <summary>
        /// 现病史
        /// 患者现在疾病的发生、发展过程
        /// </summary>
        [Required]
        [StringLength(2000)]
        [Column("PresentIllness")]
        public string PresentIllness { get; set; } = string.Empty;

        /// <summary>
        /// 既往史
        /// 患者既往疾病史、手术史、外伤史等
        /// </summary>
        [StringLength(1000)]
        [Column("PastHistory")]
        public string PastHistory { get; set; } = string.Empty;

        /// <summary>
        /// 过敏史
        /// 患者的药物过敏史、食物过敏史等
        /// </summary>
        [StringLength(500)]
        [Column("AllergyHistory")]
        public string AllergyHistory { get; set; } = string.Empty;

        /// <summary>
        /// 个人史
        /// 患者的生活习惯、职业史、婚育史等
        /// </summary>
        [StringLength(1000)]
        [Column("PersonalHistory")]
        public string PersonalHistory { get; set; } = string.Empty;

        /// <summary>
        /// 家族史
        /// 患者家族遗传病史、家族疾病史等
        /// </summary>
        [StringLength(1000)]
        [Column("FamilyHistory")]
        public string FamilyHistory { get; set; } = string.Empty;

        /// <summary>
        /// 体格检查
        /// 生命体征、各系统检查结果
        /// </summary>
        [StringLength(2000)]
        [Column("PhysicalExam")]
        public string PhysicalExam { get; set; } = string.Empty;

        /// <summary>
        /// 辅助检查
        /// 实验室检查、影像学检查等结果
        /// </summary>
        [StringLength(2000)]
        [Column("AuxiliaryExam")]
        public string AuxiliaryExam { get; set; } = string.Empty;

        /// <summary>
        /// 治疗建议
        /// 诊断结果和治疗方案，包括用药方案、注意事项等
        /// </summary>
        [Required]
        [StringLength(2000)]
        [Column("TreatmentAdvice")]
        public string TreatmentAdvice { get; set; } = string.Empty;

        /// <summary>
        /// 医生姓名
        /// 创建病历的医生
        /// </summary>
        [Required]
        [StringLength(50)]
        [Column("Doctor")]
        public string Doctor { get; set; } = string.Empty;

        /// <summary>
        /// 创建时间
        /// </summary>
        [Required]
        [Column("CreateTime")]
        public DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 更新时间
        /// </summary>
        [Required]
        [Column("UpdateTime")]
        public DateTime UpdateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 是否启用
        /// true-启用，false-禁用
        /// </summary>
        [Required]
        [Column("IsEnable")]
        public bool IsEnable { get; set; } = true;

        /// <summary>
        /// 导航属性：关联的患者信息
        /// </summary>
        [ForeignKey("PatientId")]
        public virtual PatientModel? Patient { get; set; }
    }
}